from core.models import Request
from django_community.models import UserProfile
from django_multivoting.models import Vote
import django_utils.pagination as pagination
from django.contrib.contenttypes.models import ContentType
from django.core.urlresolvers import reverse

def profile_builder(user):
    context = {}
    user.linked_profile = UserProfile.objects.get_user_profile(user)
    relevant_requests = Vote.objects.voted_objects_by_user(user, Request)
    
    requests_page,  requests_page_range = \
        pagination.paginate_queryset_ajax(relevant_requests,  10,  5,  1,  'requests_page_', 
                                reverse('community-relevant-requests',  args=[user.id]))
    context['profile_user'] = user
    context['requests_page'], context['requests_page_range'] = requests_page, requests_page_range
    return context